package com.windfone.service.impl;

import java.util.List;

import com.windfone.common.FileTool;
import com.windfone.dao.ProductDao;
import com.windfone.model.Product;
import com.windfone.service.ProductService;

public class ProductServiceImpl implements ProductService {
	private ProductDao productDao;
	public ProductDao getProductDao() {
		return productDao;
	}

	public void setProductDao(ProductDao productDao) {
		this.productDao = productDao;
	}

	public int deleteProduct(int keyValue) {
		Product bean = productDao.getProductById(keyValue).get(0);
		String suffix = bean.getImagepath();
		FileTool.dealPic(suffix );
		return productDao.deleteProduct(keyValue);
	}

	public int getAllRecorderNumber(String whereCondition) {
		return productDao.getAllRecorderNumber(whereCondition);
	}

	public int updateProduct(Product bean) {
		return productDao.updateProduct(bean);
	}

	public int insertProduct(Product bean) {
		return productDao.insertProduct(bean);
	}

	public List<Product> getProductById(int keyValue) {
		return productDao.getProductById(keyValue);
	}

	public List<Product> getAllProduct(int beginRecord,String whereCondition) {
		return productDao.getAllProduct(beginRecord,whereCondition);
	}

	public List<Product> getCommendProductByCommendType(String recommendTypeName){
		return productDao.getCommendProductByCommendType( recommendTypeName );
	}

	public List<Product> getAllProductByStatus(int typeId,int status) {
		return productDao.getAllProductByStatus(typeId,status);
	}

	public List<Product> getAllProductByWherecondition(String whereStr) {
		return productDao.getAllProductByWherecondition(whereStr);
	}

	public int updateProductStatus(int id, int status) {
		return productDao.updateProductStatus(id, status);
	}

//	public List<Product> getHotMachine() {
//		return productDao.getHotMachine();
//	}

}
